//
//  SecondTabHotDetailsViewController.m
//  项目A --半糖
//
//  Created by romana on 16/6/1.
//  Copyright © 2016年 romana. All rights reserved.
//

#import "SecondTabHotDetailsViewController.h"

@interface SecondTabHotDetailsViewController ()<UIWebViewDelegate>

@end

@implementation SecondTabHotDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.font = [UIFont systemFontOfSize:20];
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    if (self.nameStr) {
        titleLabel.text = self.nameStr;
    }else{
        titleLabel.text = @"热门详情";
    }
    
    self.navigationItem.titleView = titleLabel;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    
    if ([self.type isEqualToString:@"items"]) {
        [self createItemsData];
        //        self.title = @"礼物详情";
    }else{
        
        [self createPostsData];
        //        self.title = @"攻略详情";
        
    }
    // Do any additional setup after loading the view.
}

- (void)createPostsData{
    UIWebView *webV = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:webV];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.liwushuo.com/posts/%@",self.myUrl]];
    NSLog(@"@@@@@@@@     %@        ",self.myUrl);
    NSURLRequest *requst = [NSURLRequest requestWithURL:url];
    [webV loadRequest:requst];
    webV.delegate = self;
    
    
}

- (void)createItemsData{
    
    UIWebView *webV = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 49)];
    [self.view addSubview:webV];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.liwushuo.com/items/%@",self.myUrl]];
    //    NSLog(@"@@@@@@@@     %@        ",self.myUrl);
    NSURLRequest *requst = [NSURLRequest requestWithURL:url];
    [webV loadRequest:requst];
    webV.delegate = self;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
